; > $.Asm8051.Hdr.Hardware

        GBLL    MouseHiNibble   ; TRUE <=> mouse quadrature is in top 4 bits

MouseHiNibble SETL {TRUE}       ; new configuration

; Bits in TCON (Timer/Counter Control Register)

TF1     Bit     TCON, 7
TR1     Bit     TCON, 6
TF0     Bit     TCON, 5
TR0     Bit     TCON, 4
IE1     Bit     TCON, 3
IT1     Bit     TCON, 2
IE0     Bit     TCON, 1
IT0     Bit     TCON, 0

; Bits in SCON (Serial Port Control Register)

SM0     Bit     SCON, 7
SM1     Bit     SCON, 6
SM2     Bit     SCON, 5
REN     Bit     SCON, 4
TB8     Bit     SCON, 3
RB8     Bit     SCON, 2
TI      Bit     SCON, 1
RI      Bit     SCON, 0

; Bits in IE (Interrupt Enable Register)

EA      Bit     IE, 7
ES      Bit     IE, 4
ET1     Bit     IE, 3
EX1     Bit     IE, 2
ET0     Bit     IE, 1
EX0     Bit     IE, 0

MainInput       *       P0      ; input from main key matrix
ShiftInput      *       P1      ; input from shifting key matrix
KBIDInput       *       P1
KBIDMask        Bit     P1, 0   ; bit 0 of P1 is for reading the kbid as well

MouseInput      *       P2
MatrixOutput    *       P2

        [ MouseHiNibble
MouseMask       *       &F0
        |
MouseMask       *       &0F
        ]

SerialDataIn    Bit     P3, 0   ; but not needed as the chip gives us a byte
SerialDataOut   Bit     P3, 1   ; ditto
CapsLockLED     Bit     P3, 2
ScrollLockLED   Bit     P3, 3
NumLockLED      Bit     P3, 4
MouseButton1    Bit     P3, 5
MouseButton2    Bit     P3, 6
MouseButton3    Bit     P3, 7
MouseButtonInput *      P3
MouseButtonMask  *      &E0
MouseButtonShift *      5       ; mouse key info starts at bit 5
LEDMask          *      &1C

        END
